﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using l1cs.server.model.Instance;
using l1cs.server.serverpackets;

namespace l1cs.server.clientpackets
{
    public class C_ChangeHeading : ClientBasePacket
    {
        private const String _C_CHANGE_HEADING = "[C] C_ChangeHeading";
        private static Logger _log = Logger.getLogger( typeof( C_ChangeHeading ).FullName );

        public C_ChangeHeading( byte[] decrypt, ClientThread client )
            : base( decrypt )
        {
            int heading = readC();

            L1PcInstance pc = client.getActiveChar();

            pc.setHeading( heading );

            _log.finest( "Change Heading : " + pc.getHeading() );

            if ( pc.isGmInvis() || pc.isGhost() )
            {
            }
            else if ( pc.isInvisble() )
            {
                pc.broadcastPacketForFindInvis( new S_ChangeHeading( pc ), true );
            }
            else
            {
                pc.broadcastPacket( new S_ChangeHeading( pc ) );
            }
        }

        override
        public String getType()
        {
            return _C_CHANGE_HEADING;
        }
    }
}